package com.tjvib.view.dialog;

import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.tjvib.R;

public class HintDialog extends Dialog {

    private String con_txt = "确认";

    public HintDialog(@NonNull Context context) {
        super(context);
    }

    public void showDialog(Context context, String tit, String con,
                           View.OnClickListener confir, View.OnClickListener cancel) {
        if (tit.equals(""))
            tit = "提示";

        View view = LayoutInflater.from(context).inflate(R.layout.dialog_hint, null);
        this.setContentView(view);
        this.setCanceledOnTouchOutside(false);
        this.show();

        TextView dialog_hint_tv_tit = this.findViewById(R.id.dialog_hint_tv_tit);
        dialog_hint_tv_tit.setText(tit);

        TextView dialog_hint_tv_con = this.findViewById(R.id.dialog_hint_tv_con);
        dialog_hint_tv_con.setText(con);

        Button dialog_hint_btn_confirm = this.findViewById(R.id.dialog_hint_btn_confirm);
        dialog_hint_btn_confirm.setText(con_txt);
        dialog_hint_btn_confirm.setOnClickListener(confir);

        this.findViewById(R.id.dialog_hint_btn_cancel).setOnClickListener(cancel);
    }


    public void setConfirmText(String txt) {
        con_txt = txt;
    }
}
